package com.company.Lab1;

import java.util.Scanner;

public class Optimist {
    public static void main(String[] args) {
        int optimistArr[][];
        int rmax[] = new int[10];
        int maxiMax = 0;
        Scanner scanner = new Scanner(System.in);
        int r, c;

        System.out.println("Introducerti numarul de randuri : ");
        r = scanner.nextInt();
        System.out.println("Introduceti numarul de coloane : ");
        c = scanner.nextInt();

        optimistArr = new int[r][c];

        System.out.println("Introduceti datele matrcii :");

        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                System.out.print("[" + i + "][" + j + "] : ");
                optimistArr[i][j] = scanner.nextInt();
            }
        }

        //calculele
        for (int i = 0; i < r; i++) {
            int max = optimistArr[i][1];
            for (int j = 0; j < c; j++) {
                if (max <= optimistArr[i][j]) {
                    max = optimistArr[i][j];
                }
            }
            rmax[i] = max;
        }
        System.out.println("Valorile maxime pe rand sunt : ");
        for (int i = 0; i < r; i++) {
            System.out.println(rmax[i] + "\t");
        }

        int maxMax = rmax[0];
        for (int i = 0; i < rmax.length; i++) {
            maxMax = Math.max(maxMax, rmax[i]);
            maxiMax = maxMax;
        }
        System.out.println("Valoarea maximax : " + maxiMax);
    }
}
